﻿using Framework.EntityFramework;

namespace Framework.DataAccess
{
    public class UnitOfWork : IUnitOfWork
    {
        #region IUnitOfWork Members
        private readonly IDatabaseFactory _databaseFactory;
        private DomainContext _db;

        public UnitOfWork(IDatabaseFactory databaseFactory)
        {
            _databaseFactory = databaseFactory;            
        }

        protected DomainContext DomainContext
        {
            get { return _db ?? (_db = _databaseFactory.Get()); }
        }

        public void Commit()
        {
            DomainContext.SaveChanges();
        }
        #endregion                     
          
    }
}
